//
//  LonglinkManager.hpp
//  tarsim
//
//  Created by lanhy on 2022/3/22.
//

#ifndef LonglinkManager_hpp
#define LonglinkManager_hpp

#include <stdio.h>
#include <map>
#include <mutex>
#include "util/tc_singleton.h"

#include "gamoosim.h"

struct LongLink{
    ClientContext context;
    int    deviceType;   //设备类型：1：ios，2：android，3：windows PC,4:Mac OS
    std::string deviceName;   //设备名称
    std::string deviceID;      //设备唯一标识
    std::string version;          //客户端的版本号
    int ptclVersion;      //协议版本号
    int crypto;          //加密算法
    int compress;        //压缩算法
    
    LongLink(){
        deviceType = 0;
        ptclVersion = 0;
        crypto = 0;
        compress = 0;
    }
};

typedef shared_ptr<LongLink> LongLinkPtr;

class LongLinkManager : public tars::TC_Singleton<LongLinkManager>
{
public:
    void add(uint32_t uid, LongLinkPtr link);
    void remove(uint32_t uid);
    LongLinkPtr get(uint32_t uid);
private:
    std::mutex _mutex;
    std::map<uint32_t, LongLinkPtr> _mapLonglink;
}


#endif /* LonglinkManager_hpp */
